package com.atguigu.spzx.cloud.feign.retryer;


import feign.RetryableException;
import feign.Retryer;
import lombok.SneakyThrows;

public class FeignClientRetryer implements Retryer {
	int count = 0;
	int limit = 3;

	@SneakyThrows
	@Override
	public void continueOrPropagate(RetryableException e) {
		if (++count >= limit) {
			count = 0;
			throw new Exception("=============== 重试次数用尽 ===============");
		}
		System.out.println("=============== 重试 " + count + " 次 ===============");
	}

	@Override
	public Retryer clone() { 
		return new FeignClientRetryer();
	}
}
